// pages/myContest/myContest.js
const host=getApp().host;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    arr:[]
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.request({
      url: host+'/client/enlists/join?user='+wx.getStorageSync('admin').loginName,
      success:res=>{
        let list=res.data.data.list;
        list.forEach(item => {
          item.date=this.formatDate(item.date);
          item.time=this.formatDate(item.time);
        });
        this.setData({
          arr:list
        },()=>{
          wx.hideLoading();
        })
      }
    })
  },
  formatDate(row) {
    let date = new Date(row);
    let month =
          date.getMonth() + 1 < 10
                ? "0" + (date.getMonth() + 1)
                : date.getMonth() + 1;
    let day =
          date.getDate() < 10
                ? "0" + date.getDate()
                : date.getDate();
    return (
          date.getFullYear() +
          "-" +
          month +
          "-" +
          day 
    );
  }, 
})